axios.defaults.baseURL = 'http://www.itcbc.com:8000'
const token = localStorage.getItem('token')


axios.interceptors.request.use(function (config) {
  if (token) {
    config.headers.Authorization = token
  }
  return config
}, e => {
  return Promise.reject(e)
})

axios.interceptors.response.use(res => {
  return res
}, e => {
  if (e.response.status === 401) {
    Toast.fail('请重新登录')
    setTimeout(() => {
      window.parent.location.href = './login.html'
    }, 1000)
  }
  return Promise.reject(e)
})